perl math operators

230

perl math operators -

# Basic math operators:
|     Meaning    | Operator | Example     |
|:--------------:|:--------:|-------------|
| Addition       | +        | print 2+3;  |
| Subtraction    | -        | print 2-3;  |
| Multiplication | *        | print 2*3;  |
| Division       | /        | print 2/3;  |
| Modulus        | %        | print 2%3;  |
| Exponentiation | **       | print 2**3; |
# Note, the modulus operator is with the sigil that denotes a hash variable

# Basic math functions:
|         Function        |   Syntax  |
|:-----------------------:|:---------:|
| Absolute value          | abs()     |
| Integer                 | int()     |
| Natural log             | log()     |
| Square root             | sqrt()    |
| Random number up to num | rand(num) |
| Sinusoid                | sin()     |

Comments

Submit
0 Comments